package com.demo.iodemo;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

public class FileWriteDemo {
	
	public static void main(String[] args) throws UnsupportedEncodingException, IOException{
		String fileName = "temp.txt";
		witeToFile(fileName, "line num\t"+1+"\t2344556\t 电视剧 、电影\n");
		
		FileReadDemo.readFileByFileReader(fileName);
		new File(fileName).delete();
	}
	
	public static void witeToFile(String fileName, String data) throws UnsupportedEncodingException, IOException{
		FileOutputStream output = new FileOutputStream(fileName);//FileOutputStream(name, append) append可以设置是否追加文件内容
		witeToFileByOutputStream(output, data);
	}
	
	private static void witeToFileByOutputStream(OutputStream output, String data) throws UnsupportedEncodingException, IOException{
		output.write(data.getBytes());//getBytes中可以设置字符编码
		output.close();
	}
	
	

}
